package org.tloss.web.editor.model;

import java.util.List;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

import org.tloss.web.editor.database.editors.jdbc.Column;
import org.tloss.web.editor.database.editors.jdbc.Table;
import org.tloss.web.editor.model.oper.logical.Logical;

@XmlRootElement
public class Sql implements LogicalProvider {
	private String databaseResource;
	private String mode;
	private Database database;
	private List<Param> params;
	private List<Table> tables;
	private List<Column> updateColumns;
	private List<Logical> logicals;
	private List<Orderby> orderbies;

	@XmlAttribute
	public String getMode() {
		return mode;
	}

	public void setMode(String mode) {
		this.mode = mode;
	}

	@XmlElementWrapper(name = "update-columns")
	@XmlElement(name = "column")
	public List<Column> getUpdateColumns() {
		return updateColumns;
	}

	public void setUpdateColumns(List<Column> updateColumns) {
		this.updateColumns = updateColumns;
	}

	@XmlElementWrapper(name = "orders")
	@XmlElement(name = "order")
	public List<Orderby> getOrderbies() {
		return orderbies;
	}

	public void setOrderbies(List<Orderby> orderbies) {
		this.orderbies = orderbies;
	}

	@XmlElementWrapper(name = "logicals")
	@XmlElement(name = "logical")
	public List<Logical> getLogicals() {
		return logicals;
	}

	public void setLogicals(List<Logical> logicals) {
		this.logicals = logicals;
	}

	@XmlElementWrapper(name = "params")
	@XmlElement(name = "param")
	public List<Param> getParams() {
		return params;
	}

	public void setParams(List<Param> params) {
		this.params = params;
	}

	public void setTables(List<Table> tables) {
		this.tables = tables;
	}

	@XmlElementWrapper(name = "tables")
	@XmlElement(name = "table")
	public List<Table> getTables() {
		return tables;
	}

	@XmlTransient
	public Database getDatabase() {
		return database;
	}

	public void setDatabase(Database database) {
		this.database = database;
	}

	@XmlElement
	public String getDatabaseResource() {
		return databaseResource;
	}

	public void setDatabaseResource(String databaseResource) {
		this.databaseResource = databaseResource;
	}

}
